﻿using MPBlog.DAL;

namespace MPBlog.Core
{
    /// <summary>
    /// 博客基本设置类，保存了博客设置信息
    /// </summary>
    public class Blog
    {
        #region - variable -

        private static readonly BlogSettingDao Dao = new BlogSettingDao();

        private static string blogName = string.Empty;

        private static string blogDesc = string.Empty;

        private static string blogTheme = string.Empty;

        private static string adminTheme = string.Empty;

        private static string blogVersion = string.Empty;

        private static string blogRssUrl = string.Empty;

        private static string copyRight = string.Empty;

        #endregion


        /// <summary>
        /// 博客标题
        /// </summary>
        public static string BlogName
        {
            get
            {
                if (blogName == string.Empty)
                {
                    blogName = Dao.GetBlogSetting("BlogName");
                }
                return blogName;
            }
        }

        /// <summary>
        /// 博客副标题
        /// </summary>
        public static string BlogDesc
        {
            get
            {
                if (blogDesc == string.Empty)
                {
                    blogDesc = Dao.GetBlogSetting("BlogDescription");
                }
                return blogDesc;
            }
        }

        /// <summary>
        /// 博客主题
        /// </summary>
        public static string BlogTheme
        {
            get
            {
                if (blogTheme == string.Empty)
                {
                    blogTheme = Dao.GetBlogSetting("BlogTheme");
                }
                return blogTheme;
            }
            set { blogTheme = value; }
        }

        /// <summary>
        /// 管理界面主题
        /// </summary>
        public static string AdminTheme
        {
            get
            {
                if (adminTheme == string.Empty)
                {
                    adminTheme = Dao.GetBlogSetting("AdminTheme");
                }
                return adminTheme;
            }
            set { adminTheme = value; }
        }

        /// <summary>
        /// 博客版本
        /// </summary>
        public static string BlogVersion
        {
            get
            {
                if (blogVersion == string.Empty)
                {
                    blogVersion = Dao.GetBlogSetting("BlogVersion");
                }
                return blogVersion;
            }
            set { blogVersion = value; }
        }

        /// <summary>
        /// Rss订阅地址
        /// </summary>
        public static string BlogRssUrl
        {
            get
            {
                if (blogRssUrl == string.Empty)
                {
                    blogRssUrl = Dao.GetBlogSetting("BlogRssUrl");
                }
                return blogRssUrl;
            }
            set { blogRssUrl = value; }
        }

        /// <summary>
        /// 博客页脚的版权声明文字
        /// </summary>
        public static string CopyRight
        {
            get
            {
                if (copyRight == string.Empty)
                {
                    copyRight = Dao.GetBlogSetting("CopyRight").Replace("%BlogVersion%", BlogVersion);
                }
                return copyRight;
            }
        }
    }
}